﻿using System;
using System.Windows;
using System.Windows.Media.Animation;

namespace _3DTicTacToe.UI
{
    partial class AboutWindow : Window
    {
        readonly Duration _animationDuration = new Duration(new TimeSpan(0, 0, 0, 0, 650));
        bool _expanderState;

        public AboutWindow()
        {
            InitializeComponent();
            expGrid.Opacity = 0;
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            Close();
        }

        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            _expanderState = !_expanderState;
            if (_expanderState)
            {
                var anim = new DoubleAnimation() { To = Height + 300, AccelerationRatio = 0.25, DecelerationRatio = 0.25, Duration = _animationDuration };
                var opacityAnim = new DoubleAnimation() { To = 1, Duration = _animationDuration };
                BeginAnimation(HeightProperty, anim, HandoffBehavior.SnapshotAndReplace);
                expGrid.BeginAnimation(OpacityProperty, opacityAnim);
            } 
            else
            {
                var anim = new DoubleAnimation() { To = Height - 300, AccelerationRatio = 0.25, DecelerationRatio = 0.25, Duration = _animationDuration };
                var opacityAnim = new DoubleAnimation() { To = 0, Duration = _animationDuration };
                BeginAnimation(HeightProperty, anim, HandoffBehavior.SnapshotAndReplace);
                expGrid.BeginAnimation(OpacityProperty, opacityAnim);
            }
        }
    }
}
